<?
/*
 * scrumbrella - Scrum board.
 *
 * Copyright (C) 2009  Gustavo N. Borgoni <gborgoni@voicemedia.com.ar>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

require_once("layout_config.php");
require_once("PHPTAL.php");

include("include/permission.php");
include("include/html_utils.php");
include("include/task.php");
include("include/project.php");

// Check for user logged in
$user_id = permission_redirect_user("index.php");

if ($_SERVER['REQUEST_METHOD'] == "POST") {
	$backlog = $_REQUEST['pbacklog'];
	$estimation = $_REQUEST['estimation'];
	$unit       = $_REQUEST['unit'];

	task_add($backlog, $estimation, $unit, $user_id);
}
	// Load the template
	$temp = new PHPTAL('templates/task_add.xhtml');

	$temp->theme 	   = "themes/default/forms.css";
	$temp->title 	   = _("New task");
	$temp->prj_backlog = _("Project backlog");
	$temp->estimate    = _("Estimation");	
	$temp->unit 	   = _("Unit");
	$temp->project     = $_SESSION['project'];

	$temp->backlog = html_select_pbacklog($_REQUEST['project'], $user_id);
	$temp->units   = html_select_unitlist();

	// Error msg
	$temp->pbacklog_required = _("You must select a project backlog");
	$temp->estimation_required = _("You must insert the estimation");
	$temp->unit_required = _("You must select an estimation unit");

	try 
	{
		echo $temp->execute();
	}

	catch(Exception $e)
	{
		echo $e;
	}
?>
